package com.cy.sqlSession;

import com.cy.config.XmlConfiguration;
import com.cy.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuild {

    private Configuration configuration;

    public SqlSessionFactoryBuild() {
        this.configuration = new Configuration();
    }

    public SqlSessionFactory build(InputStream in) throws PropertyVetoException, DocumentException, ClassNotFoundException {
        //解析sqlMapConfig.xml
        XmlConfiguration xmlConfiguration = new XmlConfiguration();
        Configuration configuration = xmlConfiguration.parse(in);

        return new DefaultSqlSessionFactory(configuration);
    }

}
